package com.example.module_car.ui.play

import android.os.Bundle
import android.widget.Button
import android.widget.ImageView
import android.widget.LinearLayout
import android.widget.RadioGroup
import androidx.activity.enableEdgeToEdge
import androidx.activity.viewModels
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import com.example.lib_common.base.BaseActivity
import com.example.lib_common.utils.ToastUtils
import com.example.module_car.R
import com.example.module_car.databinding.ActivityPayBinding
import com.example.module_car.model.AddCarParam
import com.example.module_car.ui.addcar.AddCarViewModel
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class PayActivity : BaseActivity<AddCarViewModel,ActivityPayBinding>() {

    override val mLayoutResId: Int =  R.layout.activity_pay
    private val mViewModel: AddCarViewModel by viewModels()

    override fun initView() {
        super.initView()
    }

    override fun initData() {
        super.initData()
        val name = intent.getStringExtra("provinces")
        mBinding.tvPlateNumber.text = name
        //返回
        mBinding.backPlay.setOnClickListener {
            onBackPressed()
        }
        mBinding.btnSubmit.setOnClickListener {
            val province = name?.substring(0,1)
            val param = AddCarParam(
                mBinding.tvPlateNumber.text.toString(),
                "小王",
                province.toString(),
                1
            )
            mViewModel.getAddCar(param)
            mViewModel.mAddCar.observe(this){
                ToastUtils.showLong(this,"支付成功，您的Id为："+it.id)
                onBackPressed()
            }
        }
        mBinding.zfb.setOnClickListener {
            mBinding.zfb.background = ContextCompat.getDrawable(this,R.drawable.play_item)
            mBinding.wx.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
            mBinding.unionPay.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
        }
        mBinding.wx.setOnClickListener {
            mBinding.zfb.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
            mBinding.wx.background = ContextCompat.getDrawable(this,R.drawable.play_item)
            mBinding.unionPay.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
        }
        mBinding.unionPay.setOnClickListener {
            mBinding.zfb.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
            mBinding.wx.background = ContextCompat.getDrawable(this,R.drawable.un_play_item)
            mBinding.unionPay.background = ContextCompat.getDrawable(this,R.drawable.play_item)
        }
    }


}